package com.zxwl.base.dao;

import com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter;
import com.zxwl.common.type.ZxwlTypeConverter;

public class Parameter
{

	private Class<?> type;
	private Object value;
	private String name;
	private String dirction;
	private Boolean fuzzy = false;
	private static ZxwlTypeConverter coverter = new ZxwlTypeConverter();
	

	public Parameter(String name,Class<?> clazz)
	{
		this.type = clazz;
		this.name = name;
	}
	
	public Class<?> findType()
	{
		return this.type;
	}
	public void setFuzzy(Boolean fuzzy)
	{
		this.fuzzy = fuzzy;
	}
	
	public Boolean getFuzzy()
	{
		return fuzzy;
	}
	
	public void setDirction(String dirction)
	{
		this.dirction = dirction;
	}
	
	public String getDirction()
	{
		return dirction;
	}
	
	Object findValue()
	{
		if(fuzzy)
		{
			return "%" + value + "%";
		}
		
		return value;
	}
	
	public Object getValue()
	{
		return value;
	}
	
	public void setValue(Object value)
	{
		this.value = coverter.convertValue(value, this.type);
	}

	public static DefaultTypeConverter getCoverter()
	{
		return coverter;
	}
	public static void setCoverter(ZxwlTypeConverter coverter)
	{
		Parameter.coverter = coverter;
	}
	
	public String getName()
	{
		return name;
	}
	
	public void setName(String name)
	{
		this.name = name;
	}
	
}
